package com.west.xu.sms.controller;

import com.west.xu.sms.domain.SmsEntity;
import com.west.xu.sms.domain.SmsMessage;
import com.west.xu.sms.service.ISmsService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class SmsController {
    private static final Logger LOG = LoggerFactory.getLogger(SmsController.class);
    @Autowired
    ISmsService smsService;

    @RequestMapping(value = "/sendSms", method = RequestMethod.POST)
    @ApiOperation(value = "发送短信", notes = "发送短信消息")
    public String selectUser(@RequestBody SmsMessage smsMessage) throws IOException {
        String respose = smsService.sendSms(smsMessage);
        LOG.info("tencent-sms -- send sms: [" + respose + "]");
        return "Success==>\n" + respose;
    }
}
